//
//  UIImage+Extension.swift
//  SwiftExercise
//
//  Created by 罗宗庆 on 2021/6/25.
//

import Foundation

extension UIImage{
    
    //模糊效果处理
   static func blurImage(image:UIImage,value:CGFloat) -> UIImage {
    
        let inputImage = CIImage(image: image)
        let filter = CIFilter(name: "CIGaussianBlur")
        filter?.setValue(inputImage, forKey: kCIInputImageKey)
        filter?.setValue(value, forKey: kCIInputRadiusKey)
        let outputImage = filter?.outputImage
        let rect = CGRect(origin: CGPoint.zero, size: image.size)
        let context = CIContext(options: nil)
        
        let cgImage = context.createCGImage(outputImage!, from: rect)
        return UIImage(cgImage: cgImage!)
    }
    
}
